﻿using System;

public partial class aspx_video_default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            using (ds_名师讲堂TableAdapters.tb_视频TableAdapter da = new ds_名师讲堂TableAdapters.tb_视频TableAdapter())
            {
                this.rpt_video.DataSource = da.GetData();
                this.rpt_video.DataBind();
            }
        }
    }

    protected void btn查询_Click(object sender, EventArgs e)
    {
        string[] condition = new string[] { txt讲座题目.Text, txt主讲人.Text, ddl学院.SelectedItem.Text };
        for (int i = 0; i < condition.Length; i++)
        {
            condition[i] = condition[i].Trim();
            if (string.IsNullOrEmpty(condition[i]))
            {
                condition[i] = "%";
            }
            else
            {
                condition[i] = string.Format("%{0}%", condition[i]);
            }
        }
        for (int i = 0; i < this.cbl条件.Items.Count; i++)
        {
            if (!this.cbl条件.Items[i].Selected)
            {
                condition[i + 1] = "%";
            }
        }
        switch (ddl搜索模式.SelectedIndex)
        {
            case 0:
                using (ds_名师讲堂TableAdapters.tb_视频TableAdapter da = new ds_名师讲堂TableAdapters.tb_视频TableAdapter())
                {
                    this.rpt_video.DataSource = da.GetDataBy模糊查询标题(condition[0]);
                }
                break;

            case 1:
                using (ds_名师讲堂TableAdapters.v_名师讲堂视频TableAdapter da = new ds_名师讲堂TableAdapters.v_名师讲堂视频TableAdapter())
                {
                    this.rpt_video.DataSource = da.GetDataBy模糊查询(condition[0], condition[1], condition[2]);
                }
                break;

            case 2:
                using (ds_名师讲堂TableAdapters.v_其他类别视频TableAdapter da = new ds_名师讲堂TableAdapters.v_其他类别视频TableAdapter())
                {
                    this.rpt_video.DataSource = da.GetDataBy模糊查询标题(condition[0]);
                }
                break;

            default:
                break;
        }
        this.rpt_video.DataBind();
    }
}